package org.bbb.library1;

import org.bbb.library1.model.Book;
import org.bbb.library1.model.Library;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.jface.resource.ImageRegistry;
import org.eclipse.ui.plugin.AbstractUIPlugin;
import org.osgi.framework.BundleContext;

public class RcpDemoPlugin extends AbstractUIPlugin {
	
	private static RcpDemoPlugin plugin;
	   public static final String PLUGIN_ID = "org.bbb.library1";

	public static RcpDemoPlugin getDefault(){
		return plugin;
	}
	

	
	   private final Library library = new Library();

	   /**
	    * Creates and returns a shared image from the given path.
	    */
	   private ImageDescriptor createImage(String path) {
	      return imageDescriptorFromPlugin(PLUGIN_ID, path);
	   }

	   public Library getLibrary() {
	      return library;
	   }

	   /*
	    * @see org.eclipse.ui.plugin.AbstractUIPlugin#initializeImageRegistry(org.eclipse.jface.resource.ImageRegistry)
	    */
	   @Override
	   protected void initializeImageRegistry(ImageRegistry reg) {
	      reg.put(ImageConstants.BOOK_ICON, createImage("icons/book.gif"));
	   }

	   /*
	    * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext)
	    */
	   @Override
	   public void start(BundleContext context) throws Exception {
	      super.start(context);
	      plugin = this;

	      // Create some test data

	   }

	   /*
	    * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext)
	    */
	   @Override
	   public void stop(BundleContext context) throws Exception {
	      plugin = null;
	      super.stop(context);
	   }
	}